//
//  CourseClassModelH.m
//  HTP
//
//  Created by admin on 15/11/9.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "CourseClassModelH.h"

@implementation CourseClassModelH
-(BOOL)saveBean{
    ClassCourse *classCourse = [ClassCourse findFirstByAttribute:@"cgcId" withValue:self.cgcId];
    if (classCourse == nil) {
        classCourse = [ClassCourse createEntity];
    }
    classCourse.cgcId = self.cgcId;
    classCourse.cgcDate = self.cgcDate;
    classCourse.cgcStartTime = self.cgcStartTime;
    classCourse.cgcStatus = self.cgcStatus;
    classCourse.cgcStopTime = self.cgcStopTime;
    classCourse.nStatus = self.nStatus;
    classCourse.parentId = self.parentId;
    classCourse.teacherName = self.teacherName;
    classCourse.subClassName = self.className;
    classCourse.detailClassName = self.detailClassName;
    return  [XLCoreDataManager save];
}
- (BOOL)saveWithDetailName{
    ClassCourse *classCourse = [ClassCourse findFirstByAttribute:@"cgcId" withValue:self.cgcId];
    if (classCourse == nil) {
        classCourse = [ClassCourse createEntity];
    }
    classCourse.cgcId = self.cgcId;
    classCourse.cgcDate = self.cgcDate;
    classCourse.cgcStartTime = self.cgcStartTime;
    classCourse.cgcStatus = self.cgcStatus;
    classCourse.cgcStopTime = self.cgcStopTime;
    classCourse.nStatus = self.nStatus;
    classCourse.parentId = self.parentId;
    classCourse.teacherName = self.teacherName;
    classCourse.subClassName = self.className;
    classCourse.detailClassName = self.detailClassName;
    return  [XLCoreDataManager save];
}
+(id)initWithClassCourse:(ClassCourse *)classCourse{
    
    CourseClassModelH *classC = [[CourseClassModelH alloc] init];
    classC.cgcId = classCourse.cgcId;
    classC.cgcDate = classCourse.cgcDate;
    classC.cgcStartTime = classCourse.cgcStartTime;
    classC.cgcStatus = classCourse.cgcStatus;
    classC.cgcStopTime = classCourse.cgcStopTime;
    classC.nStatus = classCourse.nStatus;
    classC.parentId = classCourse.parentId;
    classC.teacherName = classCourse.teacherName;
    classC.className = classCourse.subClassName;
    classC.detailClassName = classCourse.detailClassName;
    return classC;
}
+(NSArray *)creatClassCourseTimes:(NSArray *)classCourses{
    NSMutableArray *dataArray = [[NSMutableArray alloc] init];
    [classCourses enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ClassCourse *classCourse = (ClassCourse *)obj;
        [dataArray addObject:[CourseClassModelH initWithClassCourse:classCourse]];
    }];
    return [NSArray arrayWithArray:dataArray];
}
@end
